#include "Access.h"



Access::Access(Id* base, Expr* offset, Type* type)
	:Expr(new Token((int)tag::ARRAY,"[]"))
{
	this->base = base;
	this->offset = offset;
	this->type = type;
}


Access::~Access()
{
}

string Access::ToRTL()
{
	return base->ToRTL() + "[" + offset->ToRTL() + "]";
}

Expr * Access::reduce()
{
	Expr* t= this->offset->reduce();
	Temp* des = new Temp();
	RTL::putData(new Token(tag::ARRAY, "[]"), this->base, t, des);
	return des;
}
